<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>Vue</title>
    <link rel="stylesheet" href="/css/common.css">
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.14"></script>
</head><body>
<div id="app">
    <h1>{{ appName }}</h1>
    <button @click="doChangeCmp('CmpA')">Show A</button>
    <button @click="doChangeCmp('CmpB')">Show B</button>
    <component v-bind:is="currentCmp"></component>
</div>
<script type="text/javascript">
    const CmpA = { template: `<div>Componet A</div>` }
    const CmpB = { template: `<div>Componet B</div>` }
    const app = new Vue({
        el: '#app',
        data: { appName: 'My App', currentCmp: '' },
        components: { 'CmpA': CmpA, 'CmpB': CmpB, },
        methods: {
            doChangeCmp (param) {
                this.currentCmp = param
            }
        }
    })
</script></body></html>
